package com.manor.im.data

import androidx.lifecycle.MutableLiveData
import com.manor.im.bean.PhoneUserBean

/**
 *


 * @date  2020/7/17  16:26
 * @version 1.0
 */
object PhoneUserData {

    val mList: MutableLiveData<MutableList<PhoneUserBean>> by lazy {
        MutableLiveData<MutableList<PhoneUserBean>>()
    }

    fun getPos(pos: Int): PhoneUserBean? {
        val list = mList.value ?: mutableListOf()
        if (list.size > pos) {
            return list[pos]
        }
        return null
    }


    fun addData(data: PhoneUserBean) {
        val list = mList.value ?: mutableListOf()
        list.add(data)
        mList.value = list
    }

    fun addData(data: MutableList<PhoneUserBean>) {
        mList.value = data
    }

    fun changeAttentionStatus(pos: Int) {
        val list = mList.value ?: mutableListOf()
        if (list.size > pos) {
            list[pos].isAttention = if (list[pos].isAttention =="1") "0" else "1"
            mList.value = list
        }
    }


    fun clear() {
        mList.value = mutableListOf()
    }


}